<?php
class LilgalleryHelper extends Helper {
	var $helpers = array('Html');
	
	function thumb($image, $options = array()) {
		return $this->Html->image(Configure::read('LilgalleryPlugin.thumbsUrl').
			$image['gallery_id'].'/'.
			$image['filename'], $options);
	}

	function link($title, $image=null, $htmlAttributes=array(), $confirmMessage=false, $escapeTitle=true) {
		return $this->Html->link($title, array('plugin'=>'lilgallery', 'controller'=>'images', 'action'=>'view', $image['id']),
			$htmlAttributes, $confirmMessage, $escapeTitle);
	}
	
	function image($image, $options = array()) {
		return $this->Html->image(Configure::read('LilgalleryPlugin.imagesUrl').
			$image['gallery_id'].'/'.
			$image['filename'], $options);
	}
	
	function imageUrl($image) {
		return Router::url(Configure::read('LilgalleryPlugin.imagesUrl').
			$image['gallery_id'].'/'.
			$image['filename'], true);
	}
	
	function imageWidth($image) {
		$data = getimagesize(WWW_ROOT.'img'.DS.'galleries'.DS.$image['gallery_id'].DS.$image['filename']);
		return $data[0];
	}
	
	function imageHeight($image) {
		$data = getimagesize(WWW_ROOT.'img'.DS.'galleries'.DS.$image['gallery_id'].DS.$image['filename']);
		return $data[1];
	}
}
?>